#!/usr/bin/php
<?php
include_once( "common.php" );
#$INTERNAL_COMMAND_TYPE = 0x000000FF;
$INTERNAL_COMMAND_TYPE = 0x00000401;
$TYPE = 0x00000000;
$LEN = 16;
$ID = 8;
function retrieve_doc_by_id( $id ) 
{
    global $INTERNAL_COMMAND_TYPE;
    global $TYPE;
    global $LEN;
    $sock = get_socket();
    $request = pack('NNNN', $LEN, $TYPE, $INTERNAL_COMMAND_TYPE, $id );
    socket_set_block( $sock );
    socket_set_option( $sock, SOL_SOCKET, SO_LINGER, array("l_onoff"=>1, "l_linger"=>0) );
    socket_write( $sock, $request, 16 );
    $buf = socket_read( $sock, 16 );
    $res = unpack('N*', $buf );
    print_r( $res );
    socket_close( $sock );
    usleep(1000);
}
retrieve_doc_by_id( 1 );
retrieve_doc_by_id( 5 );
retrieve_doc_by_id( 8 );
?>
